/**
 * 
 */
package com.noahsloan.groovy.algorithms

import java.io.OutputStreamWriter

/**
 * @author noah
 *
 */
public class TestGraph extends GroovyTestCase{
	
	def graph
	def dot = """\
strict digraph Foo {
  a -> b;
  b -> c;
  c -> a;
}
"""
	
	void setUp() {
		graph = new Graph(name:'Foo',nodes:[
			foo:[outgoing:["a -> b","b -> c","c -> a"]]
		])
	}
	
	void testWriteTo() {
		def baos = new ByteArrayOutputStream()
		// XXX can't use a StringWriter b/c it has extra methods that not all
		// Writers have
		new OutputStreamWriter(baos).withWriter {
			it << graph
		}
		assertEquals(dot ,baos.toString())
	}
	
	void testToString() {
		assertEquals(dot,graph.toString())
	}
}
